package com.graph;

public class Solution1376 {
    public int numOfMinutes(int n, int headID, int[] manager, int[] informTime) {
        int res = 0;
        for (int i = 0; i < manager.length; i++) {
            if (informTime[i] == 0) {
                int tmp = 0;
                int index = i;
                while (index != -1) {
                    tmp += informTime[index];
                    index = manager[index];
                }
                res = Math.max(res, tmp);
            }
        }
        return res;
    }
}
